package com.weeasy.login.controller;

import com.weeasy.core.common.Result;
import com.weeasy.login.service.LoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 微信登录控制器
 * 
 * @author we-easy
 * @since 1.0.0
 */
@RestController
@RequestMapping("/login")
@RequiredArgsConstructor
@CrossOrigin(origins = "*")
public class LoginController {

    private final LoginService loginService;

    /**
     * 微信一键登录
     * 
     * @return 登录结果
     */
    @PostMapping("/quick")
    public Result<String> quickLogin() {
        String result = loginService.quickLogin();
        return Result.success("一键登录成功", result);
    }

    /**
     * 微信授权登录
     * 
     * @param code 授权码
     * @return 登录结果
     */
    @PostMapping("/auth")
    public Result<String> authLogin(@RequestParam String code) {
        String result = loginService.authLogin(code);
        return Result.success("授权登录成功", result);
    }

    /**
     * 获取登录状态
     * 
     * @return 登录状态
     */
    @GetMapping("/status")
    public Result<Boolean> getLoginStatus() {
        Boolean status = loginService.getLoginStatus();
        return Result.success("获取登录状态成功", status);
    }
}
